iqtins_claim = {
	name = CB_NAME_CLAIM
	war_name = WAR_NAME_CLAIM_IQT
	sprite = 1
	truce_days = 3650
	hostile_against_others = yes
	can_ask_to_join_war = no
	
	press_claim = yes

	infamy_modifier = 0.85
	
	sort_priority = 1000
	
	can_use_gui = {
		always = no
	}

	can_use_title = {

	}

	is_valid_title = {
		OR = {
			FROM = {
				has_landed_title = PREV
			}
			holder_scope = {
				is_liege_or_above = FROM
			}
		}
		ROOT = { has_claim = PREV }
	}

	on_add = {
		hidden_tooltip = { fire_haruspicy_event_effect = yes }
		if = {
			limit = { defender = { is_offmap_governor = offmap_china } }
			attacker = {  
				sound_effect = china_angered_emperor
				detract_grace_super_huge_effect = yes 
			}
		}
	}

	on_success_title = {
		defender = {
			primary_title = {
				clr_title_flag = iqtaprimarytitle
			}	
		}
		hidden_tooltip = {
			ROOT = {
				clr_character_flag = claimant_adventurer
				if = {
					limit = {
						has_nickname = no
						lower_tier_than = PREV
					}
					random = {
						chance = 10
						give_nickname = nick_the_usurper
					}
				}
			}
		}
	
		usurp_title_plus_barony_if_unlanded = { target = ROOT type = claim }
		
		if = {
			limit = {
				higher_tier_than = BARON
				NOT = { culture = ROOT }
			}
			hidden_tooltip = { conquest_culture = ROOT }
		}
		
		ROOT = {
			decadence = 50
			show_scope_change = no
			participation_scaled_prestige = 100
		}
		any_attacker = {
			limit = { NOT = { character = ROOT } }
			hidden_tooltip = { participation_scaled_prestige = 100 }
		}
		
		FROM = {
			show_scope_change = no
			prestige = -100
		}

		hidden_tooltip = {
			check_war_effect = yes
			FROM = {
				landless_pope_effect = yes
			}
		}
	}

	on_fail_title = {
		defender = {
			primary_title = {
				clr_title_flag = iqtaprimarytitle
			}			
		}
		ROOT = {
			show_scope_change = no
			prestige = 100
			occupy_minors_of_occupied_settlements = FROM
			gain_all_occupied_titles = FROM
			set_defacto_liege = THIS
			hidden_tooltip = {
				#disband_event_forces = yes
				clr_character_flag = claimant_adventurer
			}
		}
		FROM = {
			decadence = 25
			show_scope_change = no
			participation_scaled_prestige = -100
		}
		any_defender = {
			limit = { NOT = { character = FROM } }
			hidden_tooltip = { participation_scaled_prestige = 100 }
		}
	}

	on_reverse_demand = {
		ROOT = {
			show_scope_change = no
			prestige = -150
			transfer_scaled_wealth = {
				to = FROM
				value = 4.0
			}
		}
		if = {
			limit = {
				ROOT = { has_character_flag = claimant_adventurer }
			}
			ROOT = { imprison = FROM }
		}
		FROM = {
			show_scope_change = no
			participation_scaled_prestige = 150
		}
		any_defender = {
			limit = { NOT = { character = FROM } }
			hidden_tooltip = { participation_scaled_prestige = 150 }
		}
		hidden_effect = {
			ROOT = {
				if = {
					limit = {
						has_landed_title = e_china_west_governor
					}
					log = "China War Logging: China lost a claim war against [From.GetBestName]"
				}
				if = { #Makes China have a chance of leaving Expanionist policy...
					limit = {
						has_landed_title = e_china_west_governor
						offmap_china = {
							has_policy = china_expansionist
						}
					}
					random = {
						chance = 50
						offmap_china = {
							set_policy = china_open
							log = "-------------------------------------"
							log = "China Policy Logging:"
							log = "Chinas new Policy is now OPEN"
							log = "-------------------------------------"
						}
					}
				}
			}
		}
	}

	on_reverse_demand_title = {
		defender = {
			primary_title = {
				clr_title_flag = iqtaprimarytitle
			}				
		}
		#any_claim = { #Does not work.
			#remove_claim = ROOT
		#}
		ROOT = { show_scope_change = no remove_claim = PREV }
		ROOT = {
			hidden_tooltip = {
				disband_event_forces = yes
				clr_character_flag = claimant_adventurer
			}
		}
	}
	
	on_attacker_leader_death = {
		defender = {
			primary_title = {
				clr_title_flag = iqtaprimarytitle
			}				
		}
		if = {
			limit = {
				ROOT = { has_character_flag = EoD_prophet_attacker }
			}
			FROM = { narrative_event = { id = RIP.15116 } }
		}
		if = {
			limit = {
				ROOT = { 
					OR = {
						has_character_flag = claimant_adventurer
						has_character_flag = EoD_prophet_attacker
					}
				}
			}
			ROOT = {
				hidden_tooltip = {
					disband_event_forces = yes
					clr_character_flag = claimant_adventurer
					clr_character_flag = EoD_prophet_attacker
				}
			}
			end_war = invalid
		}

	}

	attacker_ai_victory_worth = {
		factor = -1 # always accept
	}
	
	attacker_ai_defeat_worth = {
		factor = 100
	}

	defender_ai_victory_worth = {
		factor = -1 # always accept
	}
	
	defender_ai_defeat_worth = {
		factor = 100
	}
}